package cn.itcast.tanhua.mytanhuaserver.service.impl;

import cn.itcast.tanhua.mytanhuaserver.mapper.UserInfoMapper;
import cn.itcast.tanhua.mytanhuaserver.service.UserInfoService;
import cn.itcast.tanhua.pojo.UserInfo;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author 郭文亮
 * @since 2021/11/26 0:35
 */
@Service
public class UserInfoServiceImpl implements UserInfoService {

    @Autowired
    private UserInfoMapper userInfoMapper;

    /**
     * 通过userId查询user信息
     * @param userId 用户的id
     * @return 用户的信息
     */
    @Override
    public UserInfo queryUserInfoByUserId(Long userId) {
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper();
        queryWrapper.eq("user_id",userId);
        return this.userInfoMapper.selectOne(queryWrapper);
    }

    /**
     * 通过查询条件，查询出推荐用户的信息
     * @param queryWrapper 查询条件
     * @return 查询的推荐用户的信息
     */
    @Override
    public List<UserInfo> queryUserInfoList(QueryWrapper<UserInfo> queryWrapper) {
        return this.userInfoMapper.selectList(queryWrapper);
    }

    @Override
    public List<UserInfo> queryUserInfoListByUserIds(List<Object> userIds) {
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("user_id",userIds);
        return this.userInfoMapper.selectList(queryWrapper);
    }

    /**
     * 通过查询条件 查询出黑名单列表用户信息
     * @param userIds
     * @return
     */
    @Override
    public List<UserInfo> queryUserInfoByUserIdList(List<Object> userIds) {
        QueryWrapper<UserInfo> queryWrapper = new QueryWrapper<>();
        queryWrapper.in("user_id",userIds);
        return this.userInfoMapper.selectList(queryWrapper);
    }
}
